import java.sql.*;

public class ConnectionDemo {
    public static void main(String[] args) throws ClassNotFoundException,SQLException{
        Class.forName("com.mysql.jdbc.Driver");
        String jdbcUrl="jdbc:mysql://localhost:3308/demo";
        String user="root";
        String password="";
        try(Connection conn = DriverManager.getConnection(jdbcUrl,user,password)){
            System.out.printf("已打开数据库连接");
        } catch (SQLException e){
            System.out.println("已关闭数据库连接");
        }
    }
}
